/*
100pts but hack
in:

10
7
41 20 50 18 25 -23 -32 
10
8 35 -49 49 -27 8 33 8 36 16 
5
-16 4 -17 -38 -25 
8
-12 -7 -47 4 42 30 4 -36 
8
-17 -3 15 -7 -27 -35 17 35 
10
-6 49 -21 49 47 20 17 41 -39 27 
8
2 44 36 -45 -8 -15 -9 16 
10
1 33 -15 11 15 -10 19 -42 37 -5 
6
40 19 45 -28 34 42 
8
10 5 4 -47 -7 -37 23 21 
ans:

-1              -1
47628           47628
-1              -1
3528            3528
8925            8925
-4182 <-failed  -2754 <-pass
10800           10800
10545           10545
27132           27132
39997           39997
*/

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <set>

using ll = int64_t;
using std::cin, std::cout;

const ll maxn = 1e5+5;
ll t, n, a[maxn], ans, inf=(1l<<(sizeof(inf)*8-4));

int main(){
    std::iostream::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    cin>>t;
    while(t--){
        ans = -inf;
        cin>>n;
        std::multiset<ll> lset, rset;
        for(ll i{1};i<=n;i++){
            cin>>a[i];
            rset.emplace(a[i]);
        }
        
        // if(auto it{rset.find(a[1])};it!=rset.end())[[likely]]{
            rset.erase(rset.find(a[1]));
        // }else{
        //     throw std::runtime_error("unreachable");
        // }
        lset.emplace(a[1]);
        for(ll i{2};i<n;i++){
            rset.erase(rset.find(a[i]));
            // if(a[i]==0){
            //     ans=std::max(a[i], 0l);
            //     continue;
            // }
            // cout<<*lset.rbegin()<<' '<<a[i]<<' '<<*rset.rbegin()<<'\n';
            const auto check_ans = [](const ll &a, const ll &b, const ll &c)->void{
                // cout<<a<<' '<<b<<' '<<c<<'\n';
                if(a<b&&b<c){
                    ans=std::max(ans,a*b*c);
                }
            };
            {
                auto lit = lset.lower_bound(a[i]);
                if(lit==lset.end())--lit;
                while(*lit>=a[i]){
                    if(lit==lset.begin())goto out;
                    --lit;
                }
                if(lit!=lset.end()){
                    check_ans(*lit, a[i], *rset.rbegin());
                }
            }
            out:;
            {
                if(auto it = rset.lower_bound(a[i]);it!=rset.end()){
                    check_ans(*lset.begin() , a[i], *it);
                }
            }
            
            //-8 -4 10
            check_ans(*lset.begin(),a[i],*rset.rbegin());

            lset.emplace(a[i]);
        }
        cout<<(ans==-inf?-1:ans)<<'\n';
    }
}